package cn.iocoder.yudao.module.promotion.controller.admin.prizedraw;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.PrizeDrawSettingRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.prizedraw.PrizeDrawSettingDO;
import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 -抽奖设置")
@RestController
@RequestMapping("/promotion/prize-draw-setting")
@Validated
public class PrizeDrawSettingController {

    @Resource
    private PrizeDrawSettingService prizeDrawSettingService;

    @PostMapping("/getPrizeDrawSettingInfo")
    @Operation(summary = "查询抽奖设置详情信息")
    @PreAuthorize("@ss.hasPermission('promotion:prize-draw-setting:query')")
    public CommonResult<PrizeDrawSettingRespVO> getPrizeDrawSettingInfo() {
        return success(prizeDrawSettingService.getPrizeDrawSettingInfo());
    }

    @Operation(summary = "抽奖设置管理")
    @PutMapping
    @PreAuthorize("@ss.hasPermission('promotion:prize-draw-setting:update')")
    public CommonResult<Boolean> edit(@Validated @RequestBody PrizeDrawSettingDO setting) {
        prizeDrawSettingService.preserve(setting);
        return success(true);
    }

}